<?php
namespace app\admin\controller\v1;
use app\common\model\Exchange as ExchangeModel;

class Exchange extends BaseController
{
    public function getAll(){
        $where = input('get.');
        $res =ExchangeModel::getAll($where);
        $res = collection($res)->toArray();
        return successReturn($res);
    }
    public function getByUserId($user_id){
        $where = input('get.');
        $res = ExchangeModel::getByUserId($user_id,$where);
        return successReturn($res);
    }
    public function statistics(){
        $data = input('post.');
        $condition = $data['condition']?implode(',',$data['condition']):'id';
//        print_r(input('post.'));
        $where = [];
        $res = ExchangeModel::where($where)->
        field('*,count(1) as count')->group($condition)->select();
//        echo ExchangeModel::getLastSql();
        $res = collection($res)->toArray();
        print_r($res);
    }
}
